<?php
/**
 * #Celebrate Shieh
 *             ,%%%%%%%%,
 *           ,%%/\%%%%/\%%
 *          ,%%%\c "" J/%%%
 * %.       %%%%/ o  o \%%%
 * `%%.     %%%%    _  |%%%
 *  `%%     `%%%%(__Y__)%%'
 *  //       ;%%%%`\-/%%%'
 * ((       /  `%%%%%%%'
 *  \\    .'          |
 *   \\  /       \  | |
 *    \\/         ) | |
 *     \         /_ | |__
 *     (___________))))))) 攻城湿
 *
 *        _       _
 * __   _(_)_   _(_) __ _ _ __
 * \ \ / / \ \ / / |/ _` |'_ \
 *  \ V /| |\ V /| | (_| | | | |
 *   \_/ |_| \_/ |_|\__,_|_| |_|
 */

namespace App\Models\Blog;

use Illuminate\Database\Eloquent\Model;

class Link extends Model
{
    protected $guarded = [];

    public function file()
    {
        return $this->hasOne('App\Models\System\File', 'id', 'pic');
    }

    public function user()
    {
        return $this->belongsTo('App\User');
    }

    static function GetModel( $where = [], $with = [], $select = [ '*' ], $limit = 0, $column = 'updated_at', $direction = 'desc' )
    {
        return self::with($with)->where($where)->select($select)->orderBy($column, $direction)->paginate($limit ? : config('page.page'));
    }

    static function CreateModel( $data )
    {
        return self::create($data);
    }

    static function FindModel( $id, $select = [ '*' ] )
    {
        return self::select($select)->find($id);
    }

    static function DestroyModel( $id )
    {
        return self::destroy($id);
    }

    static function UpdateModel( $where = [], $data = [] )
    {
        return self::where($where)->update($data);
    }

    static function FirstModel( $where = [], $with = [], $select = [ '*' ] )
    {
        return self::with($with)->where($where)->select($select)->first();
    }

    static function DeleteModel( $where )
    {
        return self::where($where)->delete();
    }
}
